package manifest

import (
	"bytes"
	"kumachan/standalone/rpc/vd"
)

type Module struct {
	UniqueId      string
	Description   string
	Dependencies  [] Dependency
}
type Dependency struct {
	ImportName  string
	ModulePath  string
}

var ts, _ = vd.CreateGoStructTransformer(vd.GoStructOptions {
	Records: [] interface{} { Module{}, Dependency{} },
})
func Load(content ([] byte)) (Module, error) {
	var obj, _, err = vd.Deserialize(bytes.NewReader(content), ts.Deserializer)
	if err != nil { return Module {}, err }
	return obj.(Module), nil
}
func Store(mod Module) ([] byte) {
	var buf bytes.Buffer
	var err = vd.Serialize(mod, ts.Serializer, &buf)
	if err != nil { panic(err) }
	return buf.Bytes()
}


